package com.itheima.tlias.controller;

import com.alibaba.fastjson.JSONObject;
import com.itheima.tlias.dto.ReportDegreeCountDTO;
import com.itheima.tlias.dto.ReportGenderCountDTO;
import com.itheima.tlias.dto.StudentCountDTO;
import com.itheima.tlias.service.EmpService;
import com.itheima.tlias.service.StudentService;
import com.itheima.tlias.util.ResultUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;
import java.util.stream.Collectors;

@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/report")
public class ReportController {

    @Resource
    EmpService empService;

    @Resource
    StudentService studentService;

    @GetMapping("/empGenderData")
    public ResultUtil empGenderData(){
        List<ReportGenderCountDTO> dto = empService.empGenderData();
        return ResultUtil.success(dto);
    }

    @GetMapping("/empJobData")
    public ResultUtil empJobData(){
        return empService.empJobData();
    }

    @GetMapping("/studentDegreeData")
    public ResultUtil studentDegreeData(){
        List<ReportDegreeCountDTO> dto = studentService.studentDegreeData();
        return ResultUtil.success(dto);
    }

    @GetMapping("/studentCountData")
    public ResultUtil studentCountData(){
        return studentService.studentCountData();
    }
}
